package com.zimmur.service.impl.account;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.zimmur.controller.UserCenterController;
import com.zimmur.dao.account.IUserSizeInfoDao;
import com.zimmur.model.account.UserSizeInfo;
import com.zimmur.service.account.IUserSizeInfoService;
import com.zimmur.tools.PageUtil;
@Service("userSizeInfoService")
public class UserSizeInfoServiceImpl implements IUserSizeInfoService{
	private static Logger log = LoggerFactory.getLogger(UserSizeInfoServiceImpl.class);
	
	@Resource
	private IUserSizeInfoDao userSizeInfoDao;
	
	
	@Override
	public List<UserSizeInfo> selectByUserIdList(long userId) {
		return userSizeInfoDao.selectByUserIdList(userId);
	}


	@Override
	public PageUtil<UserSizeInfo> selectByUserIdPage(long userId, Integer pageNow) {
		PageUtil<UserSizeInfo> page = new PageUtil<>();
		try {
			Integer totalRecord = userSizeInfoDao.selectCountMySize(userId);
			if(totalRecord > 0){
				page.setTotalRecord(totalRecord);
				page.setPageNo(pageNow);
				page.setUserId(userId);
				List<UserSizeInfo> list = userSizeInfoDao.selectByUserIdPage(page);
				if(!list.isEmpty() && list.size() > 0){
					page.setItemList(list);
				}
			}
		} catch (Exception e) {
			log.error(e.getMessage());
		}
		return page;
	}


	@Override
	public int insertSelective(UserSizeInfo record) {
		return userSizeInfoDao.insertSelective(record);
	}


	@Override
	public UserSizeInfo selectByPrimaryKey(Long recid) {
		return userSizeInfoDao.selectByPrimaryKey(recid);
	}


	@Override
	public int updateByPrimaryKeySelective(UserSizeInfo record) {
		return userSizeInfoDao.updateByPrimaryKeySelective(record);
	}
}
